home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
spoc88
/
edt
/
testdays.pas
< prev
Wrap
Pascal/Delphi Source File
|
1988-06-08
|
1KB
|
67 lines
program TestDays;
uses CRT; { for ClrScr, GoToXY, ClrEol }
type
Days = (Sun, Mon, Tues, Wed, Thurs, Fri, Sat, endDay);
const
DayName : array[Days] of string[5]
= ('Sun','Mon','Tues','Wed','Thurs','Fri','Sat','');
var
Today,Tomorrow : Days;
function ToUpper(S : string) : string;
var
I,Len : word;
Ch : char;
begin
Len := Length(S);
for I := 1 to Len do begin
Ch := S[I];
if ('a' <= Ch) and (Ch <= 'z')
then S[I] := Chr(Ord(Ch)-32)
end;
ToUpper := S
end; { of func ToUpper }
function GetDay(Prompt : string) : Days;
{
writes out Prompt at (1,1) -- continues to prompt until
the user enters a valid day name (Sun..Sat); case doesn't
matter -- returns the day value entered
}
var
Ans : string[5];
Day : Days;
begin
repeat
GoToXY(1,1); ClrEol;
Write(Prompt);
Readln(Ans);
Ans := ToUpper(Ans);
Day := Sun;
while (Day <= Sat) and (Ans <> ToUpper(DayName[Day])) do
Day := Succ(Day)
until Day <> endDay;
GetDay := Day
end; { of func GetDay }
begin { main body }
ClrScr;
Today := GetDay('Which day of the week is today? ');
Tomorrow := Succ(Today);
if Tomorrow = endDay
then Tomorrow := Sun;
Writeln('Tomorrow is : ',DayName[Tomorrow])
end. { of program TestDays }